home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 1 / PC World Interactive 1 - Nisan 1997.iso / nostalji / bbs / music / sbbook.arj / SBBOOK / SOURCE / TP / PLAYVOCX.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1993-11-23  |  3.9 KB  |  129 lines

  1. (*********************************************************************
  2. *
  3. *  PROGRAM NAME: PLAYVOCX.PAS
  4. *
  5. *  COMPILER:     Borland Turbo Pascal ver. 4 or later
  6. *
  7. *  DESCRIPTION: Plays a .VOC file from extended memory using the
  8. *               CT-VOICE.DRV driver (accessed from SBSIM).  To run
  9. *               the program, type the following at the command line:
  10. *
  11. *               PLAYVOCX FILENAME
  12. *
  13. *               Where FILENAME is the drive/path/filename of the .VOC
  14. *               file to play.
  15. *
  16. *  NOTE: SBSIM driver must be loaded before running this program.
  17. *
  18. *********************************************************************)
  19.  
  20. program playvocx;
  21. uses dos,crt;
  22.  
  23. const VOC_MEM_DRIVER = $04;
  24.  
  25. {$I drvrfunc.pas}
  26.  
  27. var Command:char;
  28.     UserQuit:boolean;
  29.     RetValue:simerr;
  30.     FileName:string;
  31.     FileHandle:integer;
  32.     SBSIMHandle:integer;
  33.  
  34. (********************************************************************)
  35. begin (* main *)
  36.  
  37. if paramcount <> 1  (* no. of parameters entered on command line *)
  38. then begin
  39.      writeln('Command line must contain EXACTLY ONE filename parameter!');
  40.      halt;   (* Terminate program *)
  41.      end;
  42.  
  43. (*--- SEE IF SBSIM DRIVER HAS LOADED --*)
  44. SIMint := FindDvr('SBSIM', $0103);  (* Get SBSIM's interrupt no. *)
  45. if SIMint = 0
  46. then begin
  47.      writeln('SBSIM driver not loaded!');
  48.      halt;   (* Terminate program *)
  49.      end;
  50.  
  51. (*--- SEE IF CT-VOICE.DRV DRIVER HAS LOADED -------*)
  52. if (GetDrvrs and VOC_MEM_DRIVER) <> VOC_MEM_DRIVER
  53. then begin
  54.      writeln('CT-VOICE.DRV not loaded!');
  55.      halt;  (* Terminate program *)
  56.      end;
  57.  
  58. (*--- OPEN FILE SPECIFIED ON COMMAND LINE ------*)
  59. FileHandle := DosOpen(paramstr(1), ReadAccess);
  60. if (FileHandle = -1)
  61. then begin
  62.      writeln('FILE: ',paramstr(1), ' not successfully opened!');
  63.      halt;    (* Terminate program *)
  64.      end;
  65.  
  66. DosClose(FileHandle);  (* Done with the file, close it! *)
  67.  
  68.  
  69. Filename:=paramstr(1);  (* copy to string with more space before modifying *)
  70.  
  71. (*--- LOAD THE FILE INTO EXTENDED MEMORY ----------*)
  72. if not LoadExtMem(AsciiZ(Filename), SBSIMHandle)
  73. then begin
  74.      writeln('ERROR CALLING SBSIM: ', errorMsg[simerr(SBSIMHandle)]);
  75.      halt;    (* Terminate program *)
  76.      end;
  77.  
  78.  
  79. (*--- StartSnd() INITIALIZES THE CT-VOICE DRIVER -----------*)
  80. RetValue := StartSnd(MemVoice, nil, true, SBSIMHandle);
  81. if RetValue <> SIMerr_NoErr
  82. then begin
  83.      writeln('ERROR CALLING SBSIM: ', errorMsg[RetValue]);
  84.      halt;  (* Terminate program *)
  85.      end;
  86.  
  87. (*--- PlaySnd() BEGINS PLAYING OF THE FILE ----------*)
  88. RetValue := PlaySnd(MemVoice);
  89. if RetValue <> SIMerr_NoErr
  90. then begin
  91.      writeln('ERROR CALLING SBSIM: ', errorMsg[RetValue]);
  92.      if FreeExtMem(SBSIMHandle) <> SIMerr_NoErr
  93.      then writeln('ERROR: Error freeing extended memory');
  94.      halt;  (* Terminate program *)
  95.      end;
  96.  
  97.  
  98. clrscr;  (* Clear screen *)
  99. writeln(#10#10#10#10#10'     SELECT ONE OF THE FOLLOWING OR WAIT UNTIL DONE:');
  100. writeln('                   (P)ause');
  101. writeln('                   (R)esume');
  102. writeln('                   (Q)uit');
  103.  
  104. UserQuit := false;
  105.  
  106. (*--- PROCESS USER INTERACTION OR WAIT FOR SOUND TO STOP -----------*)
  107. repeat
  108.      if (keypressed)  (* Was a key pressed? *)
  109.      then begin
  110.           Command := upcase(readkey);  (* Get char that's in buffer *)
  111.           if Command = 'P'
  112.           then PauseSnd(MemVoice)
  113.           else if Command = 'R'
  114.           then ResumeSnd(MemVoice)
  115.           else if Command = 'Q'
  116.           then UserQuit := true;
  117.           end;
  118. (* Exit do-while loop if file is done playing or user typed 'Q' *)
  119. until (UserQuit = true) or (GetSndStat(MemVoice) = 0);
  120.  
  121. (*--- IF SOUND IS STILL PLAYING AND USER HIT 'Q', STOP THE SOUND ---*)
  122. if (GetSndStat(MemVoice) <> 0) and (UserQuit = true)
  123. then StopSnd(MemVoice);
  124.  
  125. (*--- FREE UP EXTENDED MEMORY THAT FILE WAS LOADED INTO ------------*)
  126. if FreeExtMem(SBSIMHandle) <> SIMerr_NoErr
  127. then writeln('ERROR: Error freeing extended memory');
  128.  
  129. end.